/*
 * EnigmaGM - A feature rich guild management system.
 * Copyright (C) 2007 ajiaojr.
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 */
package org.ajiaojr.enigmagm.client.data;

import org.ajiaojr.enigmagm.client.security.Privilege;

import java.io.Serializable;

public class User implements Serializable {
  /**
   * 
   */
  private static final long serialVersionUID = 2625444305991674754L;

  private long privilege;

  private String username;

  public User() {
  }

  public User(String username, long privilege) {
    this.username = username;
    this.privilege = privilege;
  }

  public String getUsername() {
    return username;
  }

  public boolean hasPrivilege(long privilege) {
    return (this.privilege & privilege) != 0;
  }

  public boolean isAdmin() {
    return ((privilege | Privilege.SIGN_UP | Privilege.SIGN_OFF) ^ (Privilege.SIGN_UP | Privilege.SIGN_OFF)) != 0;
  }

  public void setUsername(String username) {
    this.username = username;
  }
}
